//package com.island.gomallorder.interceptor;
//
//import com.island.gomallorder.common.constant.AuthServerConstant;
//import com.island.gomallorder.vo.MemberResponseVo;
//import org.springframework.util.AntPathMatcher;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
///**
// * 登录拦截器，未登录的用户不能进入订单服务
// */
//public class LoginInterceptor implements HandlerInterceptor {
//    public static ThreadLocal<MemberResponseVo> loginUser = new ThreadLocal<>();
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        String requestURI = request.getRequestURI();
//        //路径匹配器
//        AntPathMatcher matcher = new AntPathMatcher();
//        boolean match1 = matcher.match("/order/order/infoByOrderSn/**", requestURI);
//        boolean match2 = matcher.match("/payed/**", requestURI);
//        if (match1||match2) return true;
//
//        HttpSession session = request.getSession();
//        MemberResponseVo memberResponseVo = (MemberResponseVo) session.getAttribute(AuthServerConstant.LOGIN_USER);
//        if (memberResponseVo != null) {
//            loginUser.set(memberResponseVo);
//            return true;
//        }else {
//            session.setAttribute("msg","请先登录");
//            response.sendRedirect("http://auth.gulimall.com/login.html");
//            return false;
//        }
//    }
//
//    @Override
//    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//
//    }
//
//    @Override
//    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//
//    }
//}
